package collection.map2.hashmap;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.junit.Test;

public class HashMapDemo {

	Map<Object, Object> map = new HashMap<Object, Object>();

	@Test
	public void testPut() {
		// 无序
		// 键和值都可以为null
		map.put("M", "M");
		map.put("B", null);
		map.put("C", null);
		map.put(null, "D");
		map.put("E", "E");
		map.put(null, "E");
		map.put("map", map);
		map.put(2, "2017");
		map.put(new Date(), "2017");
		System.out.println(map);
	}

	@Test
	public void testKeySet() {
		testPut();
		Set<Object> set = map.keySet();
		System.out.println(set);
	}

	@Test
	public void testValues() {
		testPut();
		Collection<Object> coll = map.values();
		System.out.println(coll);
	}

	@Test
	public void testEntrySet() {
		map.put("A", "B");
		map.put("C", "D");
		Set<Map.Entry<Object, Object>> set = map.entrySet();
		System.out.println(set);
	}

}
